<?php
/**
 * ApiRedis
 *
 */

class ApiRedis {

	private $_servers;
	public  $_redis = null;

	private function __construct($config = array())
	{
		$this->_servers = $config;
		$this->_redis = new Redis;
		$this->_redis->connect($config['host'], $config['port'], 2);
	}

    public static function getInstance ()
    {
    	global $REDIS_CONFIG;

		static $instances = array();

		$index 	= serialize($REDIS_CONFIG);
		if(isset($instances[$index]))
			return $instances[$index];

		$class 	= __CLASS__;
		$obj = new $class($REDIS_CONFIG);
		$instances[$index] = $obj->_redis;

		return $obj->_redis;
    }
}
